<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //定义函数
        function getweb() {
            let web = "shanxinshuo.codetest"
            return web
        }
        console.log(getweb())

        //传参数
        function add(num) {
            return num + 10
        }
        console.log(add(2))
        //默认值（如果传参了用参数，没传参用默认值）
        function getpage(page = 5) {
            return page
        }
        console.log(getpage())
        console.log(getpage(1))
        //匿名函数：只是不用给函数起名——>一般用于ajax succeess
        let sub = function (x, y) {
            return x + y
        }
        console.log(sub(1, 2))
        //箭头函数（匿名函数简化版):去掉function改成箭头
        let arrow = (x, y) => {
            return x + y
        }
        console.log(arrow(1, 5))
        //隐式返回(箭头函数简化版):去掉大括号和return
        let plus = (a, b) => a + b
        console.log(plus(1, 9))
    </script>
</body>

</html>